package com.example.javabasic.thread.classtwo.workthread.demo2;

import com.example.javabasic.thread.classtwo.workthread.demo2.future.FutureService;
import com.example.javabasic.thread.classtwo.workthread.demo2.future.TaskFuture;

/**
 * @description 测试Future和 生产着消费者
 * @Author Lin FuYuan
 * @date 2021/2/25
 */
public class Test {
    public static void main(String[] args) throws InterruptedException {
//        FutureService futureService = new FutureService();
//        TaskFuture<String> kaishi = futureService.submit(() -> {
//            System.out.println("kaishi");
//            Thread.sleep(1000);
//            return "hello";
//        });
////        String s = kaishi.get();
//        System.out.println("结束");
//        System.out.println(kaishi.get());


        TaskQueue queue = new TaskQueue(100);
        TaskFuture hallo = queue.put(() -> {
            System.out.println("hallo");
            return "done";
        });
        System.out.println(hallo.get());


    }
}
